/*     */ package com.qmsk.business.task.trytime.controller;
/*     */ 
/*     */ import com.qmsk.business.task.trytime.dao.TryTimeDao;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import java.util.HashMap;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"tryTime"})
/*     */ public class TryTimeController
/*     */ {
/*  35 */   private static final Logger logger = Logger.getLogger(TryTimeController.class);
/*     */ 
/*     */   @Autowired
/*     */   private TryTimeDao dao;
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/id/{id}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId, @PathVariable("id") String id, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  56 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  58 */       Map params = new HashMap();
/*  59 */       params.put("shopId", shopId);
/*  60 */       MapUtils.addToMap(params, "id", id);
/*  61 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(params, nPageIdx, 
/*  62 */         nPageSize);
/*  63 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  65 */       logger.error(e);
/*  66 */       ResponseUtils.setErrorMsgResponse(
/*  67 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/opt/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListShopIdOpt(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  86 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  88 */       Map params = new HashMap();
/*  89 */       params.put("shopId", shopId);
/*  90 */       MapUtils.addToMap(params, "id", RequestUtils.getStringOfId(request));
/*  91 */       MapUtils.addPercentToMap(params, "code", 
/*  92 */         RequestUtils.getString(request, "code"));
/*  93 */       MapUtils.addPercentToMap(params, "name", 
/*  94 */         RequestUtils.getString(request, "name"));
/*  95 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(params, nPageIdx, 
/*  96 */         nPageSize);
/*  97 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  99 */       logger.error(e);
/* 100 */       ResponseUtils.setErrorMsgResponse(
/* 101 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/timeList/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void gettimeList(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId)
/*     */   {
/*     */     try
/*     */     {
/* 155 */       Map params = new HashMap();
/* 156 */       params.put("ShopID", shopId);
/* 157 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(params);
/* 158 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 160 */       logger.error(e);
/* 161 */       ResponseUtils.setErrorMsgResponse(
/* 162 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"insert/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/* 180 */       int nResult = 0;
/* 181 */       Long id = null;
/* 182 */       String sData = RequestUtils.getStringOfData(request);
/* 183 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 184 */       if (p != null) {
/* 185 */         nResult = this.dao.applyUpdates(p);
/* 186 */         if (nResult > 0) {
/* 187 */           id = this.dao.getLastId();
/* 188 */           DbConnection.commit();
/*     */         } else {
/* 190 */           DbConnection.rollback();
/*     */         }
/*     */       }
/* 193 */       if (id != null) {
/* 194 */         String[] heads = { "id" };
/* 195 */         Object[] datas = { id };
/* 196 */         ResponseUtils.toGsonEbRst(heads, datas, response);
/* 197 */         return; }
/* 198 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 199 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 200 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 203 */       logger.error(e);
/* 204 */       DbConnection.rollback();
/* 205 */       ResponseUtils.setErrorMsgResponse(
/* 206 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 207 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"edit/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void edit(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/* 224 */       int nResult = 0;
/* 225 */       String sData = RequestUtils.getStringOfData(request);
/* 226 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 227 */       if (p != null) {
/* 228 */         nResult = this.dao.applyUpdates(p);
/* 229 */         if (nResult > 0)
/* 230 */           DbConnection.commit();
/*     */         else {
/* 232 */           DbConnection.rollback();
/*     */         }
/*     */       }
/* 235 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 236 */         RequestUtils.getSqlUpdateDataErrorMessage(request), 
/* 237 */         response);
/*     */     } catch (Exception e) {
/* 239 */       logger.error(e);
/* 240 */       DbConnection.rollback();
/* 241 */       ResponseUtils.setErrorMsgResponse(
/* 242 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 243 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"del/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 259 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 261 */       String[] strParams = id.split(",");
/* 262 */       int nResult = this.dao.deleteParams(strParams);
/* 263 */       if (nResult > 0)
/* 264 */         DbConnection.commit();
/*     */       else {
/* 266 */         DbConnection.rollback();
/*     */       }
/* 268 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 269 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 270 */         response);
/*     */     } catch (Exception e) {
/* 272 */       DbConnection.rollback();
/* 273 */       logger.error(e);
/* 274 */       ResponseUtils.setErrorMsgResponse(
/* 275 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 276 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.task.trytime.controller.TryTimeController
 * JD-Core Version:    0.5.3
 */